<?php
class Student{
	function Student(){
		include("student.methodTable.php");
		include("database.php");
	}
	function getStudent($studentId){
		if (isset($studentId)) $WHERE = " WHERE userId={$studentId} AND pcn != '' "; else $WHERE = " WHERE pcn != '' ";
		$sql = "SELECT * FROM user $WHERE";
		$query = mysql_query($sql);
		return $query;
	}
	function getProjectStudents($projectId){
		if (isset($projectId)) $WHERE .= " WHERE project_user.projectId={$projectId}";
		$sql = "SELECT project_user.userId FROM project_user INNER JOIN project ON project.projectId = project_user.projectId $WHERE";
		$query = mysql_query($sql);
		return $query;
	}
	function getRating($studentId){
		if (isset($studentId)) {
			$WHERE = " WHERE project_user.userId={$studentId}";
			$sql = "SELECT AVG(rating.rating) AS rating FROM rating INNER JOIN project_user ON rating.projectId = project_user.projectId $WHERE";
			$query = mysql_query($sql);
			return $query;
		} else return false;
	}
}
?>